<template>
    <a-row v-if="this.headContentColumns.length > 0" class="detail-layout">
      <template v-for="(item, index) in headContentColumns">
        <a-col :span="colSpan(index)">
          <div class="contentText">{{item.title}}</div>
          <div class="contentHeading">
            <template v-if="!item.len || item.len === 0">
              {{headContent[item.dataIndex]}}
            </template>
            <template v-if="item.len && item.len > 0">
              <j-ellipsis :value="headContent[item.dataIndex]" :length="item.len"/>
            </template>
          </div>
        </a-col>
      </template>
    </a-row>
</template>

<script>

  export default {
    name: 'YqPageHeadContent',
    components: {},
    created() {
    },
    data() {
      return {
        rowNum: 1
      }
    },
    props:{
      headContent:{},
      headContentColumns: {
        type:Array,
        required:false,
        default:[]
      }
    },
    computed:{
    },
    methods: {
      colSpan(index) {
        let colLength = this.headContentColumns.length
        if (colLength === 0 || this.rowNum === 0) {
          return 0;
        } else {
          let mod = 24 % Math.ceil(colLength / this.rowNum);
          let sp = Math.floor(24 / Math.ceil(colLength / this.rowNum))
          if (mod > 0 && index > (colLength - mod - 1)) {
            return sp + 1;
          } else {
            return sp;
          }
        }
      }
    }
  }
</script>

<style lang="less" scoped>
  .detail-layout {
    margin-left: 2px;
  }
  .contentText {
    color: rgba(0, 0, 0, .45);
    font-size: 13px;
    margin-top: 6px;
  }
  .contentHeading {
    color: rgba(0, 0, 0, .85);
    font-size: 14px;
  }
</style>